<template>
<div style="height:600px;box-sizing:border-box;padding:0 20px;overflow-y: auto; ">
   <el-button class="filter-item" size="mini" type="success" icon="el-icon-back"  @click="back">返回</el-button>	
   <el-button class="filter-item" size="mini" type="success" icon="el-icon-circle-check"  @click="addRisk">保存</el-button>
  <div class="head_title">新增预警信息</div>
  <el-form ref="form" :model="form"  :rules="addRules" style="margin-top: 16px;" size="small" label-width="180px">
	<el-form-item label="客户编号"   style="display:inline-block;width:48%;">
         <el-input v-model="form.custNum" :disabled="true" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="客户名称"   style="display:inline-block;width:48%;">
         <el-input v-model="form.custName" :disabled="true" style="width: 370px;"/>
    </el-form-item>
    <el-form-item label="预警级别"  prop="rWarnLevel" style="display:inline-block;width:48%;">
           <el-select v-model="form.rWarnLevel"  placeholder="请先选择预警级别" style="width: 370px;">
				<el-option
					v-for="item in dictMap.riskwarn_level"
					:key="item.id"
					:label="item.label"
					:value="item.value"/>
          </el-select>
    </el-form-item>
	<el-form-item label="预警信息来源"  prop="rWarnOrigin" style="display:inline-block;width:48%;">
           <el-select v-model="form.rWarnOrigin"  placeholder="请先选择预警信息来源" style="width: 370px;">
				<el-option
					v-for="item in dictMap.warn_origin"
					:key="item.id"
					:label="item.label"
					:value="item.value"/>
          </el-select>
      </el-form-item>
    <el-form-item label="是否采取后续行动"  prop="isTakeAction" style="display:inline-block;width:48%;">
           <el-select v-model="form.isTakeAction"  placeholder="请先选择是否采取后续行动" style="width: 370px;">
				<el-option
					v-for="item in dictMap.yes_no"
					:key="item.id"
					:label="item.label"
					:value="item.value"/>
          </el-select>
      </el-form-item>
	    <el-form-item label="后续行动"  prop="afterAction" style="display:inline-block;width:48%;">
           <el-select v-model="form.afterAction"   placeholder="请先选择后续行动" style="width: 370px;">
				<el-option
					v-for="item in dictMap.follow_action"
					:key="item.id"
					:label="item.label"
					:value="item.value"/>
          </el-select>
      </el-form-item>
      <el-form-item label="预警日期"  prop="warnDate" style="display:inline-block;width:48%;margin-bottom:-2px">
			<el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.warnDate"  value-format="yyyy-MM-dd" style="width: 370px;" ></el-date-picker>
			</el-form-item>			
	  </el-form-item>
      <el-form-item  label="预警信息"  style="display:inline-block;width:93.1%;">
            <el-input  type="textarea"  v-model="form.warnInfo"  style="width:1170px"></el-input>
      </el-form-item>

	   <!-- <el-form-item label="录入单位"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.createDept" :disabled="true" style="width: 370px;"/>
		</el-form-item>
		<el-form-item label="录入日期" style="display:inline-block;width:48%;margin-bottom:-4px">
				<el-form-item prop="date1">
						<el-date-picker  type="date"  v-model="form.createTime" :disabled="true" style="width: 370px;" ></el-date-picker>
				</el-form-item>			
		</el-form-item>
		<el-form-item label="录入人"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.createUser" :disabled="true" style="width: 370px;"/>
        </el-form-item>
        <el-form-item label="更新日期" style="display:inline-block;width:48%;">
			<el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.updateTime" :disabled="true" style="width: 370px;" ></el-date-picker>
			</el-form-item>			
	    </el-form-item>
        <el-form-item label="更新人"   style="display:inline-block;width:48%;">
           <el-input v-model="form.updateUser"  :disabled="true" style="width: 370px;"/>
        </el-form-item> -->









	<!-- <el-form-item label="业务品种"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.busiType" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="文本合同号"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.paperContractNo" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="合同金额"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.contractAmount" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="币种"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.currency" style="width: 370px;"/>
    </el-form-item>
	 <el-form-item label="行业投向"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.industryInvest" style="width: 370px;"/>
    </el-form-item>
	<el-form-item  label="用途说明"  style="display:inline-block;width:93.1%;">
            <el-input  type="textarea"  v-model="form.use"  style="width:1170px"></el-input>
    </el-form-item>
	<el-form-item label="基准年利率"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.yearRate" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="利率浮动方式"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.rateFloatMode" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="利率浮动值"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.rateFloatVal" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="执行月利率"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.monthRate" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="利率调整方式"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.rateAdjustMode" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="还款方式"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.repayMode" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="主要担保方式"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.guaranteeMode" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="其他担保方式"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.otherGuaranteeMode" style="width: 370px;"/>
    </el-form-item>
    <el-form-item label="合同起始日" style="display:inline-block;width:48%;margin-bottom:-2px">
			<el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.contractStart" style="width: 370px;" ></el-date-picker>
			</el-form-item>			
	</el-form-item>
	 <el-form-item label="合同到期日" style="display:inline-block;width:48%;margin-bottom:-2px">
			<el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.contractEnd" style="width: 370px;" ></el-date-picker>
			</el-form-item>			
	</el-form-item>
	<el-form-item label="总余额"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.balance" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="逾期天数"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.overdueDays" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="五级分类"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.fiveKind" style="width: 370px;"/>
    </el-form-item>
    <el-form-item label="终结日期" style="display:inline-block;width:48%;margin-bottom:-4px">
			<el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.endDate" style="width: 370px;" ></el-date-picker>
			</el-form-item>			
	</el-form-item>
    <el-form-item  label="备注"  style="display:inline-block;width:93.1%;">
            <el-input  type="textarea"  v-model="form.remark"  style="width:1170px"></el-input>
    </el-form-item>
    <el-form-item label="录入人"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.createUser" style="width: 370px;"/>
    </el-form-item>
     <el-form-item label="录入机构"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.dept" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="录入日期" style="display:inline-block;width:48%;margin-bottom:-4px">
			<el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.createTime" style="width: 370px;" ></el-date-picker>
			</el-form-item>			
	</el-form-item>
    <el-form-item label="更新人"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.updateUser" style="width: 370px;"/>
    </el-form-item>
	 <el-form-item label="更新机构"  prop="deptNum" style="display:inline-block;width:48%;">
         <el-input v-model="form.updateDept" style="width: 370px;"/>
    </el-form-item>
	<el-form-item label="更新日期" style="display:inline-block;width:48%;">
			<el-form-item prop="date1">
					<el-date-picker  type="date"  v-model="form.updateTime" style="width: 370px;" ></el-date-picker>
			</el-form-item>			
	</el-form-item> -->
  </el-form>
  </div>
</template>

<script>
import { get, update } from '@/api/alipay'
import { general,list,credentials,addCredentials,effective} from '@/api/custComBaseinfo'
import { contractDetails } from '@/api/loanManageInfo'

import { addRisk} from '@/api/riskWarningInfo'

import initData from '@/mixins/initData'
import initDict from '@/mixins/initDict'
import { parseTime } from '@/utils/index'
import checkPermission from '@/utils/permission'
export default {
  name: 'Config',
  mixins: [initData, initDict],
  data() {
    return {
	  dialog:false,
	  loading: false,
	  addLoading:false,
	  id:'',
      form: { 
           custNum:'',
		   custName:'',
		   rWarnLevel:'',
		   rWarnOrigin:'',
		   isTakeAction:'',
		   afterAction:'',
		   warnDate:'',
		   warnInfo:'',
		   createDept:'',
		   createTime:'',
		   createUser:'',
		   updateTime:'',
		   updateUser:''
		 },
		  reqForm:{
			page: 0, 
			size: 10,
			sort:'orderNum,asc',
			custId:''
		},
		reqLoading:true,
		reqId:'',
		reqIds:[],
	    addForm:{
		   cardCountry:'',
		   cardType:'',
		   cardNum:'',
		   cardEndDate:'',
		   cardStatus:'',
		   cardPublishCity:'',
		   isMainCard:''
		},
		addRules: {
			    rWarnLevel:[
					{ required: true, message: '请输入预警级别', trigger: 'change' }
				],
				rWarnOrigin:[
					{ required: true, message: '请输入预警信息来源', trigger: 'change' }
				],
				isTakeAction:[
					{ required: true, message: '请输入是否采取后续行动', trigger: 'change' }
				],
				afterAction:[
					{ required: true, message: '请输入后续行动', trigger: 'change' }
				],
				warnDate:[
					{ required: true, message: '请输入预警日期', trigger: 'change' }
				],
				// cardCountry: [
				//   { required: true, message: '请输入证件国别', trigger: 'blur' }
				// ],
				// cardType: [
				//   { required: true, message: '请输入证件类型', trigger: 'blur' }
				// ],
				// cardNum: [
				//   { required: true, message: '请输入证件编号', trigger: 'blur' }
				// ],
				// cardEndDate: [
				//   { required: true, message: '请输入证件到期日期', trigger: 'blur' }
				// ],
				// cardStatus: [
				//   { required: true, message: '请输入证件状态', trigger: 'blur' }
				// ],
				// cardPublishCity: [
				//   { required: true, message: '请输入证件发布城市', trigger: 'blur' }
				// ],
		        // isMainCard: [
				//   { required: true, message: '请输入是否主证件', trigger: 'blur' }
				// ]

		},

		effectiveParams:{
		   id:'',
		   cardStatus:''
		},
      rules: {
        appID: [
          { required: true, message: '请输入appID', trigger: 'blur' }
        ],
        sysServiceProviderId: [
          { required: true, message: '请输入商家账号', trigger: 'blur' }
        ],
        privateKey: [
          { required: true, message: '商户私钥不能为空', trigger: 'blur' }
        ],
        publicKey: [
          { required: true, message: '支付宝公钥不能为空', trigger: 'blur' }
        ],
        returnUrl: [
          { required: true, message: '回调地址不能为空', trigger: 'blur' }
        ],
        notifyUrl: [
          { required: true, message: '回调地址不能为空', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
	  console.log('id----',this.$route.params.id)
	  //this.id = this.$route.params.id
	  
	  this.$nextTick(() => {
		   this.getDictMap('riskwarn_level,warn_origin,yes_no,follow_action')
	       console.log('dictMap=====',this.dictMap)
      })

	  console.log('id--------------',this.id)
	  	setTimeout(() => {
				this.form.custNum = sessionStorage.getItem('custNum')
				this.form.custName = sessionStorage.getItem('custName')
				//  this.id = sessionStorage.getItem('contractNo')
				//  console.log('this.id',this.id)
				//  this.loading = true
				//  let that = this
                //  contractDetails(this.id).then(res => {
				// 	   this.loading = false
                //       this.form = {
				// 		    custNum:res.custNum,
				// 			custName:res.custName,
				// 			busiType:res.busiType,
				// 			paperContractNo:res.paperContractNo,
				// 			contractNo:res.contractNo,
				// 			contractAmount:res.contractAmount,
				// 			currency:res.currency,
				// 			industryInvest:res.industryInvest,
				// 			use:res.use,
				// 			yearRate:res.yearRate,
				// 			rateFloatMode:res.rateFloatMode,
				// 			rateFloatVal:res.rateFloatVal,
				// 			monthRate:res.monthRate,
				// 			rateAdjustMode:res.rateAdjustMode,
				// 			repayMode:res.repayMode,
				// 			guaranteeMode:res.guaranteeMode,
				// 			otherGuaranteeMode:res.otherGuaranteeMode,
				// 			contractStart:res.contractStart,
				// 			contractEnd:res.contractEnd,
				// 			balance:res.balance,
				// 			overdueDays:res.overdueDays,
				// 			fiveKind:res.fiveKind,
				// 			endDate:res.endDate,
				// 			remark:res.remark,
				// 			createUser:res.createUser,
				// 			dept:res.dept,
				// 			createTime:res.createTime,
				// 			updateUser:res.updateUser,
				// 			updateDept:res.updateDept,
				// 			updateTime:res.updateTime,
				// 	  }
				// 	  console.log('this.form',this.form)

				
				// 	   console.log('res',res)
                //  }).catch(err => {
                //        this.loading = false
                //        console.log(err.response.data.message)
				// }) 
				


                
			   






         }, 500)
	  
  },
  methods: {
	   parseTime,
	   checkPermission,
	back(){
		// this.$router.go(-1)
		 this.$router.push('/risk-warning/risk')
	},
    addRisk(){
        if(this.form.rWarnLevel == ''||this.form.rWarnOrigin == '' || this.form.isTakeAction == '' || this.form.afterAction == '' || this.form.warnDate == ''){
			this.$message.warning('必填项未填写')
			return
		}
        const para = {
			 custNum:this.form.custNum,
		     custName:this.form.custName,
		     rWarnLevel:this.form.rWarnLevel,
		     rWarnOrigin:this.form.rWarnOrigin,
		     isTakeAction:this.form.isTakeAction,
		     afterAction:this.form.afterAction,
		     warnDate:this.form.warnDate,
		     warnInfo:this.form.warnInfo,
		}
        addRisk(para).then(res => {
		  this.$message.success('添加风险信息成功')
		  this.$router.push('/risk-warning/risk')
		}).catch(err => {
            this.loading = false
            console.log(err.response.data.message)
        })

	},
	handleSelectionChange(val) {
		  console.log('val',val)
		   val.forEach((v) => {
               this.reqIds.push(v.id)
		   });
		   console.log('ids',this.reqIds)
		   this.reqId = this.reqIds.toString()
		   this.reqIds = []
	},
	add(){
		this.dialog = true;
	},
	cancelAdd(){
		this.resetForm()
	},
	resetForm() {
      this.dialog = false
	  this.$refs['forms'].resetFields()
	  this.addForm ={
           custId:'',

		   cardCountry:'',
		   cardType:'',
		   cardNum:'',
		   cardEndDate:'',
		   cardStatus:'',
		   cardPublishCity:'',
		   isMainCard:''
	  }
	},
	
 

  }
}
</script>

<style scoped> 
  .head_title{
    height:40px;line-height:40px;border-bottom: 2px solid #ce2731;color:#ce2731
  }
  .space{
	  margin-top:30px;
	  margin-bottom:10px
  }
   .one{
	   display:inline-block;
	   width:86.5%;
   }
   .two{
	   display:inline-block;
	   width:50%;
	
   }


</style>
